import './assets/main.css'

// import { createApp } from 'vue'
import { createSSRApp } from 'vue'
// 引入了根组件
import App from './App.vue'
// import router from './router'
import { createRouter } from './router'
import { createPinia } from 'pinia'

// 引入组件库
import ElementPlus from 'element-plus'
// 引入组件库相关样式
import 'element-plus/dist/index.css'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// // 挂载根组件
// const app = createApp(App)

// // 引入图标
// for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
//   app.component(key, component)
// }

// const pinia = createPinia()

// app.use(router).use(pinia).use(ElementPlus).mount('#app')

export function createApp() {
  // 创建Vue应用实例
  const app = createSSRApp(App)
  // 创建路由实例
  const router = createRouter()
  const pinia = createPinia()

  // 引入图标
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
  app.use(router).use(pinia).use(ElementPlus)

  return { app, router, pinia }
}
